﻿@model myMvcBlog.Models.AddCommentView
<h3 id="respond">
    发表评论</h3>
<p>
    @*@if (!Model.IsKnownUser)
    {
        <a href="#" id="openIdLogin">登录</a><span>，登陆后便可删除或修改已发表的评论</span>
        <span style="color: Red;">（请注意保留评论内容）</span>
    }
    else
    {        
        @Html.ActionLink("注销", "Logout", new { controller = "Account" })
    }*@
</p>
@using (Html.BeginForm("Add", "Comment", FormMethod.Post, new { id = "commentForm", @class = "commentform" }))
{ 
    @Html.Hidden("PostID", Model.PostId);
                                       
        <p>
            <label for="Author">昵称：</label><input type="text" maxlength="20" name="Author" value="" class="author required" />（必填）
        </p>
        <p>
            <label for="Email">邮箱：</label><input type="text" maxlength="50" name="Email" value="" class="email required" />（必填，仅用于<a
                href="http://en.gravatar.com/">Gavatar</a>）
        </p>
        <p>
            <label for="Site">主页：</label><input type="text" maxlength="50" name="Site" value="" class="website" />（可选）
        </p>
    @Html.Hidden("ImageSrc", Model.ImageSrc);
    
    <p class="content">
        <label for="Content">（大于5个字符）：</label></p>
    <div>
        <!-- markItUp! toolbar settings -->
        <script type="text/javascript" src="@Url.Content("~/Content/markitup/sets/default/set.js")"></script>
        <!-- markItUp! skin -->
        <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/markitup/skins/markitup/style.css")" />
        <!--  markItUp! toolbar skin -->
        <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/markitup/sets/default/style.css")" />
        <textarea name="Content" class="content markItUpEditor required" id="commentMarkup"></textarea>
        <!-- markItUp! -->
        <script type="text/javascript" src="@Url.Content("~/Content/markitup/jquery.markitup.js")"></script>
        <script type="text/javascript">
            $('#commentMarkup').markItUp(mySettings);
        </script>
        <br />
        <input type="submit" value="发表评论" />
    </div>
}
<script type="text/javascript">
    $('#commentForm').validate({
        rules: {
            Author:"required",
            Email:{
                required:true,
                email:true
            },
            Content:{
                required:true,
                minlength:5
            }
       },
       messages:{
        Author:"",
        Email:{
            required:"",
            email:"Email地址不合法"
        },
        Content:{
            required:"",
            minlength:jQuery.format("同学，请多写一点吧")
        }
       },
    
    highlight: function (element, errorClass) {
        $(element).css("border", "1px red solid");
    }
});
</script>
@*<link href="@Url.Content("~/Content/Stylesheets/ui-lightness/jquery-ui-1.8.9.custom.css")" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $('#openIdLogin').click(function () {
        $('#openIdLoginDiv').dialog();
    });
</script>*@
@*<div id="openIdLoginDiv">
    <form id="openid-form" method="post" action="@Url.Action("OpenIdLogin", "Account")">
    <ul>
        <li id="google">
            <img src="@Url.Content("~/Content/Images/openIds/google.gif")" /></li>
        <li id="openid">
            <img src="@Url.Content("~/Content/Images/openIds/openid.png")" /></li>
        <li id="yahoo">
            <img src="@Url.Content("~/Content/Images/openIds/yahoo.gif")" /></li>
    </ul>
    @Html.Hidden("postUrl", Model.PostUrl);
    <input type="text" name="openIdUrl" id="openIdUrl" />
    <a id="signin">Sign In »</a>
    </form>
    <script type="text/javascript">
        var providers = {
            myopenid: { action: '@Url.Action("OpenIdLogin", "Account")', url: 'http://myopenid.com' },
            facebook: { action: '@Url.Action("OpenIdLogin", "Account")', url: 'http://facebook.com' },
            google: { action: '@Url.Action("OpenIdLogin", "Account")', url: 'http://www.google.com/accounts/o8/id' },
            yahoo: { action: '@Url.Action("OpenIdLogin", "Account")', url: 'http://yahoo.com' }
        };

        $("#signin").click(function () {
            $("#openid-form").submit();
        });

        $("li").not("#openid").click(function () {
            $("#other").hide(500);
            isHidden = true;
            var id = $(this).attr("id");
            var provider = providers[id];
            if (provider.action != undefined) {
                $("#openid-form").attr("action", provider.action);
            }
            if (provider.url != undefined) {
                $("#openIdUrl").val(provider.url);
            }
            $("#openid-form").submit();
        });

        var isHidden = true;
        function toggleOther() {
            if (isHidden) {
                $("#other").slideDown(500);
            } else {
                $("#other").slideUp(500);
            }
            isHidden = !isHidden;
        }

    </script>
</div>*@
